//
//  YYInvoiceVC.m
//  drivingSchool
//
//  Created by 子yu 刘 on 2018/8/11.
//  Copyright © 2018年 子yu 刘. All rights reserved.
//

#import "YYInvoiceVC.h"

@interface YYInvoiceVC ()

@end

@implementation YYInvoiceVC{
    UIButton * _lastBtn;
    NSString * _type;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    _lastBtn = self.btnNo;
   _type = @"0";
}

- (IBAction)selType:(UIButton *)sender {
    if (_lastBtn) {
        [_lastBtn setImage:DEF_IMAGENAME(@"sign_inspection vehicle_checkbox_anselected") forState:UIControlStateNormal];
    }
    [sender setImage:DEF_IMAGENAME(@"sign_inspection vehicle_checkbox") forState:UIControlStateNormal];
    switch (sender.tag) {
        case 101:
            _type = @"0";
            self.bottmeHeighe.constant = 0;
            self.bottmeView.hidden = YES;
            break;
        case 102:
            _type = @"1";
             self.bottmeView.hidden = NO;
            self.bottmeHeighe.constant = 72;
            self.tfName.hidden = YES;
            self.tfTile.placeholder = @"请输入个人姓名";
            break;
        case 103:
            _type = @"2";
             self.bottmeView.hidden = NO;
            self.bottmeHeighe.constant = 128;
             self.tfName.hidden = NO;
             self.tfTile.placeholder = @"请输入公司抬头";
            break;
            
        default:
            break;
    }
//    [UIView animateWithDuration:0.3 animations:^{
//        [self.view layoutIfNeeded];
//    }];
    _lastBtn = sender;
}


- (IBAction)corfirme:(id)sender {
    if (!_type) {
        [AlertUtil alertMessage:@"请选择发票类型"];
        return;
    }
    if ([_type isEqualToString:@"1"]) {
        if (self.tfTile.text.length==0) {
            [AlertUtil alertMessage:@"请输入个人姓名"];
            return;
        }
    }
    
    if ([_type isEqualToString:@"2"]) {
        if (self.tfTile.text.length==0) {
            [AlertUtil alertMessage:@"请输入公司的抬头"];
            return;
        }
        if (self.tfName.text.length==0) {
            [AlertUtil alertMessage:@"请输入公司纳税识别号"];
        }
    }
    if (_block) {
        self.block(_type,self.tfName.text,self.tfTile.text);
    }
    [self.navigationController popViewControllerAnimated:YES];
}


@end
